package com.yun.newBlog.blog.common;

import com.fasterxml.jackson.databind.util.BeanUtil;
import org.springframework.beans.BeanUtils;

public class BeanCopyUtils {

    public static <T> T copyProperties(Object object,Class<T> clazz) throws Exception{
        if(object == null){
            return null;
        } else {
            Object t = null;
            try{
                t = clazz.newInstance();
            } catch (Exception e){
                new Exception(clazz.getName());
            }
            BeanUtils.copyProperties(object,t);
            return (T) t;
        }
    }
}
